package com.credit.mola.app.ui.permission

import com.credit.mola.app.R
import com.credit.mola.app.app.App
import com.credit.mola.lib_permission.Permission
import org.json.JSONArray
import org.json.JSONObject

object PermHelper {

    /**
     * sms
     */
    fun getCreditMolaMESAGItem(): JSONObject {
        val item = JSONObject()
        item.put("isSystem",true)
        item.put("permission", Permission.READ_SMS)
        item.put("title", App.instance().getString(R.string.permission_sms_title))
        item.put("icon",R.mipmap.img_permission_reason_sms_icon)
        val msgArray = JSONArray()
        val obj1 = JSONObject()
        obj1.put("title", App.instance().getString(R.string.permission_sms_why))
        obj1.put("des", App.instance().getString(R.string.permission_sms_why_des))
        msgArray.put(obj1)

        val obj2 = JSONObject()
        obj2.put("title", App.instance().getString(R.string.permission_sms_can_do))
        obj2.put("des", App.instance().getString(R.string.permission_sms_can_do_des))
        msgArray.put(obj2)

        val obj3 = JSONObject()
        obj3.put("title", App.instance().getString(R.string.permission_sms_data_safety))
        obj3.put("des", App.instance().getString(R.string.permission_sms_data_safety_des1))
        msgArray.put(obj3)

        val obj4 = JSONObject()
        obj4.put("title", "")
        obj4.put("des", App.instance().getString(R.string.permission_sms_data_safety_des2))
        msgArray.put(obj4)
        item.put("msgList",msgArray)
        return item
    }

    /**
     * device
     */
    fun getCreditMolaPhoneStateItem(): JSONObject {
        val item = JSONObject()
        item.put("isSystem",false)
        item.put("permission", App.instance().getString(R.string.permission_device_title))
        item.put("title", App.instance().getString(R.string.permission_device_title))
        item.put("icon",R.mipmap.img_permission_reason_device_icon)
        val msgArray = JSONArray()
        val obj1 = JSONObject()
        obj1.put("title", "")
        obj1.put("des", App.instance().getString(R.string.permission_device_des1))
        msgArray.put(obj1)

        val obj2 = JSONObject()
        obj2.put("title", "")
        obj2.put("des", App.instance().getString(R.string.permission_device_des2))
        msgArray.put(obj2)

        val obj3 = JSONObject()
        obj3.put("title", "")
        obj3.put("des", App.instance().getString(R.string.permission_device_des3))
        msgArray.put(obj3)

        val obj4 = JSONObject()
        obj4.put("title", "")
        obj4.put("des", App.instance().getString(R.string.permission_device_des4))
        msgArray.put(obj4)

        val obj5 = JSONObject()
        obj5.put("title", "")
        obj5.put("des", App.instance().getString(R.string.permission_device_des5))
        msgArray.put(obj5)
        item.put("msgList",msgArray)
        return item
    }

    /**
     * app list
     */
    fun getCreditMolaAPListItem(): JSONObject {
        val item = JSONObject()
        item.put("isSystem",false)
        item.put("permission",App.instance().getString(R.string.permission_app_list_title))
        item.put("title", App.instance().getString(R.string.permission_app_list_title))
        item.put("icon",R.mipmap.img_permission_reason_applist_icon)
        val msgArray = JSONArray()
        val obj1 = JSONObject()
        obj1.put("title", App.instance().getString(R.string.permission_app_list_why))
        obj1.put("des", App.instance().getString(R.string.permission_app_list_why_des))
        msgArray.put(obj1)

        item.put("msgList",msgArray)
        return item
    }

    /**
     * camera
     */
    fun getCreditMolaCameraItem(): JSONObject {
        val item = JSONObject()
        item.put("isSystem",true)
        item.put("permission", Permission.CAMERA)
        item.put("title", App.instance().getString(R.string.permission_camera_title))
        item.put("titleReason",App.instance().getString(R.string.permission_camera_title))
        item.put("iconReason",R.mipmap.img_permission_reason_camera_icon)
        item.put("icon",R.mipmap.img_permission_reason_camera_icon)
        val msgArray = JSONArray()
        val obj1 = JSONObject()
        obj1.put("title", "")
        obj1.put("des", App.instance().getString(R.string.permission_camera_des1))
        msgArray.put(obj1)

        val obj2 = JSONObject()
        obj2.put("title", "")
        obj2.put("des", App.instance().getString(R.string.permission_camera_des2))
        msgArray.put(obj2)

        val obj3 = JSONObject()
        obj3.put("title", "")
        obj3.put("des", App.instance().getString(R.string.permission_camera_des3))
        msgArray.put(obj3)
        item.put("msgList",msgArray)
        return item
    }

    /**
     * storage
     */
    fun getCreditMolaStorageItem(): JSONObject {
        val item = JSONObject()
        item.put("isSystem",false)
        item.put("permission", App.instance().getString(R.string.permission_storage_title))
        item.put("title", App.instance().getString(R.string.permission_storage_title))
        item.put("icon",R.mipmap.img_permission_reason_storage_icon)
        val msgArray = JSONArray()
        val obj1 = JSONObject()
        obj1.put("title", "")
        obj1.put("des", App.instance().getString(R.string.permission_storage_des))
        msgArray.put(obj1)
        item.put("msgList",msgArray)
        return item
    }

    /**
     * contact
     */
    fun getCreditMolaPhoneBookItem(): JSONObject {
        val item = JSONObject()
        item.put("isSystem",false)
        item.put("permission", App.instance().getString(R.string.permission_contact_title))
        item.put("title", App.instance().getString(R.string.permission_contact_title))
        item.put("icon",R.mipmap.img_permission_reason_contact_icon)
        val msgArray = JSONArray()
        val obj1 = JSONObject()
        obj1.put("title", "")
        obj1.put("des", App.instance().getString(R.string.permission_contact_des))
        msgArray.put(obj1)

        item.put("msgList",msgArray)
        return item
    }

    /**
     * album
     */
    fun getCreditMolaPhotoAlbumItem(): JSONObject {
        val item = JSONObject()
        item.put("isSystem",false)
        item.put("permission", App.instance().getString(R.string.permission_album_title))
        item.put("title", App.instance().getString(R.string.permission_album_title))
        item.put("icon",R.mipmap.img_permission_reason_album_icon)
        val msgArray = JSONArray()
        val obj1 = JSONObject()
        obj1.put("title", "")
        obj1.put("des", App.instance().getString(R.string.permission_album_des))
        msgArray.put(obj1)

        item.put("msgList",msgArray)
        return item
    }
}